package cn.IT.dao.impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.stereotype.Repository;

import cn.IT.dao.IReplyDAO;
import cn.IT.dao.ITopicDAO;
import cn.IT.dao.IUserDAO;
import cn.IT.domain.Reply;
import cn.IT.domain.Topic;
import cn.IT.domain.User;

@Repository
@SuppressWarnings("all")
public class ReplyDAO extends BaseDAO<Reply> implements IReplyDAO{
	

	@Override
	public List<Reply> findByTopicId(Serializable topicId) {
		List<Reply> list = find("from Reply r where r.topic.topicId='"+topicId+"'");
		if(!list.isEmpty()){
			return list;
		}
		return null;
	}

	@Override
	public List<Reply> findByUser(User user) {
		List<Reply> list = find("from Reply r where r.user.userId='"+user.getUserId()+"'");
		if(!list.isEmpty()){
			return list;
		}
		return null;
	}
	
	@Override
	public List<Reply> findNewsByTopicUser(User user){
		List<Reply> list = find("from Reply r where r.topic.userByUserId.userId='"+user.getUserId() + "'");
		System.out.println(list.size());
		if(!list.isEmpty()){
			return list;
		}
		return null;
	}
	
	
}
